/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package workforce.limousine.service;

import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import limousine.vo.Car;
import limousine.vo.TaxiTariff;
import org.jsrpc.servlet.SessionBean;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.workforce.util.Utils;

/**
 *
 * @author krisada
 */
public class TaxiTariffManager extends SessionBean {
    
    private Service service = null;
    private DataSource dataSource = null;

    public TaxiTariffManager() {
    }

    public void init() {
        if (service == null) {
            service = (Service) WebApplicationContextUtils.getWebApplicationContext(
                    this.getServletContext()).getBean("taxiTariffService");
        }
//        if (dataSource == null) {
//            dataSource = (DataSource) WebApplicationContextUtils.getWebApplicationContext(
//                    this.getServletContext()).getBean("dataSource");
//            service.setDataSource(dataSource);
//        }
    }

    public boolean remove(String o) {
        init();
        return service.remove(o);
    }

    public boolean save(TaxiTariff o) {
        init();
        return service.save(o);
    }

    public List<TaxiTariff> search(int offset, String token) {
        init();
        //System.out.println("limit :"+ properties.getProperty("ui.limit") );
        //int limit = Integer.parseInt(properties.getProperty("ui.limit", "20"));
        List<TaxiTariff> list = service.search(offset, new Object[]{token});
        return list;
    }

    public boolean update(TaxiTariff o) {
        init();
        return service.update(o);
    }

    public TaxiTariff findById(String id) {
        init();
        return (TaxiTariff) service.findById(id);
    }

    public boolean removeAll(String ids[]) {
        return false;
    }

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }
    
    public String requestId() {
        return Utils.generateId();
    }
}
